import numpy as np
import matplotlib.pyplot as plt
import cv2
def nothing(x):
    pass
img = cv2.imread('./img/opencv.jpg')
#cv2.imshow('image0',img)
img2 = cv2.imread('./img/lesson.jpg')
#cv2.imshow('image1',img2)
cv2.namedWindow('image')
cv2.resizeWindow('image',500,500)
cv2.createTrackbar('ratio','image',0,100,nothing)


while(1):
    ratio = cv2.getTrackbarPos('ratio','image')
    #两张图必须一样大
    dst=cv2.addWeighted(img,ratio,img2,(1-ratio/100.0),0)
    cv2.imshow('image',dst)
    key=cv2.waitKey(1)&0xFF
    if key==27:#esc
        break
    elif key == ord('s'):#show
        print('ratio: ',ratio)
cv2.destroyAllWindows()